package com.jxstyle.core.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.jxstyle.core.common.Constant;

public class DateUtil {

	public static Date[] dateRange(String dateTime, String split, String pattern) throws ParseException {
		try {
			if (StringUtil.isOneEmpty(dateTime, split, pattern)) {
				return null;
			}
			String[] strArr = dateTime.split(split);
			SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
			Date[] dateArr = new Date[strArr.length];
			for (int i = 0; i < strArr.length; i++) {
				dateArr[i] = simpleDateFormat.parse(strArr[i].trim());
			}
			return dateArr;
		} catch (ParseException e) {
			e.printStackTrace();
			throw e;
		}
	}

	public static Date[] dateRange(String dateTime, String pattern) throws ParseException {
		return dateRange(dateTime, Constant.SPLIT_DEFAULT, pattern);
	}

	public static Date[] dateRange(String dateTime) throws ParseException {
		return dateRange(dateTime, Constant.SPLIT_DEFAULT, Constant.DATE_TIME_PATTERN_DEFAULT);
	}

	public static boolean isEmpty(Date dateTime) throws ParseException {
		return dateTime == null;
	}

	public static boolean isNotEmpty(Date dateTime) throws ParseException {
		return dateTime != null;
	}
}
